Death Counters
Death counts are unsigned 4-byte values that keep track of how many times a given unit had been killed for each player. When a unit is killed (by another unit, not by a kill trigger), 1 is added to the death count of that unit for whatever player owned it. All death counts for all players start at zero. The Deaths condition can be used to detect how many deaths a player has for a unit. The Set Deaths action can be used to modify the death counts. Map makers can use these counters for a variety of things other than just detecting when units get killed. They can be used to store game variables, such as the level in a defense map, or character HP in a RPG map. They can also be used as a timer. Death counter timers are a commonly used alternative to wait actions. Used in conjunction with Hyper Triggers, Death counter timers are far more useful and flexible than wait actions. The number of death counts available to map makers is very high; one for each unit for each player 1-8. Counter control Unless you are using a death counter to actually detect when a unit is killed, your triggers should have absolute control over the value of the death counter. To do this, make sure that the unit can't actually be killed in your map. The following units can never be killed, the only way their death count will change from zero is if you use the Set Deaths action. Many of these units can't be used in a map at all. Goliath Turret Tank Turret(Tank Mode) Nuclear Missile Alan Schezar Turret Edmund Duke Turret Edmund Duke Turret Tank Turret (Siege Mode) Scanner Sweep Unused - Cargo Ship Unused - Mercenary Gunship Map Revealer Disruption Web Unused1 Unused2 Uraj Crystal Khalis Crystal Unused Zerg Building1 Unused Zerg Building2 Unused Protoss Building1 Unused Protoss Building2 Khaydarin Crystal Formation Mineral Field (Type 1) Mineral Field (Type 2) Mineral Field (Type 3) Cave Cave-in Cantina Mining Platform Independant Command Center Independant Starport Independant Jump Gate Ruins Kyadarin Crystal Formation Vespene Geyser Zerg Marker Terran Marker Protoss Marker Zerg Beacon Terran Beacon Protoss Beacon Zerg Flag Beacon Terran Flag Beacon Protoss Flag Beacon Dark Swarm Floor Hatch Left Upper Level Door Right Upper Level Door Left Pit Door Right Pit Door Start Location Flag Psi Emitter Data Disc Khaydarin Crystal All of these units are either always invincible, or they crash when you place them on the map, or crash when killed, so they are good units to use for death counters. In the case of the Start Location, they can be placed on the map as units, and can be attacked and killed, adding one to the death count, but anyone who views this event will crash. Timer Any type of counter can be used as a timer, but using a death counter is the most common method, because there are many available for use. To use a counter as a timer, you must first determine how long you want it to wait. This type of counter is based on how often the triggers execute. If you are using hyper triggers on fastest, the counter will change 12 times per real-time second (the exact number is 1 trigger loop every 84 milliseconds, or approx 11.9 times per second). If you want to be compatible with the countdown timer, then the counter will change 8 times per game second. If you are not using hyper triggers, the counter will change once every two game seconds. First, set the counter to the desired amount. StarCraft Trigger template] }| Description: } |}} Players: }}}} Conditions: }}}} Actions: }}}} Make a trigger that always subtracts 1 from the counter. StarCraft Trigger template] }| Description: } |}} Players: }}}} Conditions: }}}} Actions: }}}} You can also use deathcounts to produce a series of repeatable events. However, this may only work with Hyper Triggers. StarCraft Trigger template] }| Description: } |}} Players: }}}} Conditions: }}}} Actions: }}}} StarCraft Trigger template] }| Description: } |}} Players: }}}} Conditions: }}}} Actions: }}}} Using this, you can make various events from one death count. From this, one should realize that death counts can be used for almost all repeated but timed triggers without the need of setting more conditions. This is great for triggering things like pre/post spell effects. Switch You can use death counters like switches. For example, use: StarCraft Trigger template] }| Description: } |}} Players: }}}} Conditions: }}}} Actions: }}}} in place of: StarCraft Trigger template] }| Description: } |}} Players: }}}} Conditions: }}}} Actions: }}}} With this action, you can have conditions that respond accordingly. Player will be the player number, quantity is at least, exactly, or at most a certain number, and Unit is the unit that you used to set the deaths. This gives you a huge range of switches. Even more than 255, because there is a counter for every unit for each player. This also allows you to have player-specific switches. So, for example, you could set a death counter to 1 for All Players, and have each of the players' triggers respond to this counter individually. Without using a counter this would require multiple actions and multiple switches (set switch 1, set switch 2, set switch 3, etc.) EUD For more information, see EUDs. Attempting to use "Extended Unit" or "Extended Player" death counts has an entirely different effect. For a brief period "EUD" triggers, and other "extended" triggers, were possible. Extended Unit Death triggers, a method of using the Deaths and Set Deaths conditions and actions with large values, allowed for map makers to read from or write to much of Starcraft's memory directly by means of buffer overflows. Many "mod-like" things were possible, such as giving Terran or Zerg units Protoss shields, changing what type of weapon a unit used, changing a unit's portrait and voice quotes, editing/detecting unit HP/energy, etc. Not only were these things possible, but they could also be activated in-game, and changed later during the game, which is beyond the power of a normal mod. These actions were later disabled by patch 1.13. They are currently non-functional, you can no longer set the death counts for extended units or players. You can, however, still read from memory using EUD conditions. Problems with EUD conditions are numerous. Mainly, most of them aren't particularly useful, especially without their EUD action counterparts. They also need to be updated if StarCraft is ever patched, because the memory locations change - although no longer an issue nowadays given the last patch was over 5 years ago. Some EUD Conditions will even drop players when actions are used as the values are not shared over Battle.net. Death counters over switches Death Counters provide many advantages over normal switches, however both have their place. Here's a list of times when one should choose either a switch or a death counter: Death Counters * Player-specific switches * Switches with more than two states Normal Switches * Global Switches * Two state switches * Randomization Category:StarCraft Category:Reference Category:Tutorials Category:Triggers